package io.renren.modules.doc.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import io.renren.modules.doc.entity.PromptTemplateEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import java.util.List;

@Mapper
public interface PromptTemplateDao extends BaseMapper<PromptTemplateEntity> {
    
    @Select("SELECT * FROM sys_prompt_template WHERE category = #{category} ORDER BY usage_count DESC")
    List<PromptTemplateEntity> getTemplatesByCategory(String category);
    
    @Select("SELECT * FROM sys_prompt_template ORDER BY usage_count DESC LIMIT #{limit}")
    List<PromptTemplateEntity> getPopularTemplates(int limit);
    
    @Update("UPDATE sys_prompt_template SET usage_count = usage_count + 1 WHERE id = #{id}")
    void incrementUsageCount(Long id);
}
